package com.gongfutrip.trans.client.processor;

import java.util.Random;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.gongfutrip.trans.remoting.protocol.RemotingCommand;

import io.netty.channel.ChannelHandlerContext;

public class ShoppingProcessor extends Processor {
  private static final Logger logger = LoggerFactory.getLogger(ShoppingProcessor.class);

  @Override
  public boolean rejectRequest() {
    return super.rejectRequest();
  }

  @Override
  public RemotingCommand doRequest(ChannelHandlerContext ctx, RemotingCommand request)
      throws Exception {
    RemotingCommand response = request;
    logger.info("收到请求： " + new String(request.getBody()));
    Random r = new Random();
    response.setBody((r.nextInt() + "shpping result json").getBytes());
    response.setRemark("Hi ............." + ctx.channel().remoteAddress());
    return response;
  }
}

